package com.example.hzq.zqb.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.hzq.zqb.R;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created by hzq on 2017/7/13.
 */

public class ListAdapter extends BaseAdapter {
    private List<String> name1;
    private  String[] name={ "手机通讯","平板电脑","相机单反","美妆","户外运动"};
    private Context context;
    private LayoutInflater layoutInflater;//动态加载布局
    private TextView title;
    public ListAdapter(Context context){
        this.context=context;
        layoutInflater=LayoutInflater.from(context);
    }
    @Override
    public int getCount() {
        return name.length;
    }

    @Override
    public Object getItem(int position) {
        return name1.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView=layoutInflater.inflate(R.layout.listitem, null);
        name1= Arrays.asList(name);
        title=(TextView)convertView.findViewById(R.id.list_title);
        title.setText(name1.get(position));
        return convertView;
    }
}
